package view;

import grupod.dp1.MainApplication;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

public class Menu extends javax.swing.JFrame {

    public Menu() {
        initComponents();
        
        String nombre = "Usuario:";
        nombre+=" "+MainApplication.getUsuarioActual().getNombres();
        nombre+=" "+MainApplication.getUsuarioActual().getApPaterno();
        lblNombre.setText(nombre);
        String ciudad = MainApplication.getCiudadActual().getCiudad();
        lblCiudad.setText(""+ciudad);
    }
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        btnRegistro = new javax.swing.JButton();
        btnSimulacion = new javax.swing.JButton();
        btnReportes = new javax.swing.JButton();
        btnTracking = new javax.swing.JButton();
        lblExit = new javax.swing.JLabel();
        btnCarga = new javax.swing.JButton();
        lblNombre = new javax.swing.JLabel();
        lblCiudad = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        btnAgregarUsuario = new javax.swing.JButton();
        lblCambioContrasena = new javax.swing.JLabel();

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
        jLabel1.setText("BIENVENIDO");

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("Menú Principal");
        setResizable(false);

        btnRegistro.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        btnRegistro.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/Registro.png"))); // NOI18N
        btnRegistro.setText("Registro");
        btnRegistro.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnRegistro.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnRegistro.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnRegistroMouseClicked(evt);
            }
        });

        btnSimulacion.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        btnSimulacion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/Simular.png"))); // NOI18N
        btnSimulacion.setText("Simulación");
        btnSimulacion.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnSimulacion.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnSimulacion.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnSimulacionMouseClicked(evt);
            }
        });

        btnReportes.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        btnReportes.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/Reporte_Check.png"))); // NOI18N
        btnReportes.setText("Reportes");
        btnReportes.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnReportes.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnReportes.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnReportesMouseClicked(evt);
            }
        });

        btnTracking.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        btnTracking.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/Lupa.png"))); // NOI18N
        btnTracking.setText("Tracking");
        btnTracking.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnTracking.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnTracking.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnTrackingMouseClicked(evt);
            }
        });

        lblExit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/salir.png"))); // NOI18N
        lblExit.setToolTipText("Cerrar Sesión");
        lblExit.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblExitMouseClicked(evt);
            }
        });

        btnCarga.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        btnCarga.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/dataHistorica.png"))); // NOI18N
        btnCarga.setText("Carga de Data");
        btnCarga.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnCarga.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnCarga.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnCargaMouseClicked(evt);
            }
        });

        lblNombre.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        lblNombre.setForeground(new java.awt.Color(255, 0, 0));
        lblNombre.setText("labelNombre");

        lblCiudad.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        lblCiudad.setForeground(new java.awt.Color(255, 0, 0));
        lblCiudad.setText("labelCiudad");

        jLabel5.setText("----------------------------------------------------------------------------------------------");

        btnAgregarUsuario.setFont(new java.awt.Font("Arial", 1, 18)); // NOI18N
        btnAgregarUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/agregarUsuario.png"))); // NOI18N
        btnAgregarUsuario.setText("Usuario");
        btnAgregarUsuario.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        btnAgregarUsuario.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        btnAgregarUsuario.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btnAgregarUsuarioMouseClicked(evt);
            }
        });

        lblCambioContrasena.setFont(new java.awt.Font("Arial", 1, 11)); // NOI18N
        lblCambioContrasena.setForeground(new java.awt.Color(0, 0, 255));
        lblCambioContrasena.setText("Cambiar Contraseña");
        lblCambioContrasena.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                lblCambioContrasenaMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addComponent(lblCambioContrasena))
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(lblNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 181, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(6, 6, 6)
                .addComponent(lblCiudad, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(68, 68, 68)
                .addComponent(lblExit))
            .addGroup(layout.createSequentialGroup()
                .addGap(33, 33, 33)
                .addComponent(jLabel5))
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(btnRegistro)
                .addGap(58, 58, 58)
                .addComponent(btnSimulacion))
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(btnTracking)
                .addGap(58, 58, 58)
                .addComponent(btnReportes))
            .addGroup(layout.createSequentialGroup()
                .addGap(29, 29, 29)
                .addComponent(btnAgregarUsuario)
                .addGap(58, 58, 58)
                .addComponent(btnCarga))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(lblCambioContrasena)
                .addGap(2, 2, 2)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblExit)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(9, 9, 9)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lblNombre)
                            .addComponent(lblCiudad))))
                .addGap(2, 2, 2)
                .addComponent(jLabel5)
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnRegistro)
                    .addComponent(btnSimulacion))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnTracking)
                    .addComponent(btnReportes))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnAgregarUsuario)
                    .addComponent(btnCarga)))
        );

        btnCarga.getAccessibleContext().setAccessibleName("Carga Data");

        setSize(new java.awt.Dimension(451, 656));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void lblExitMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblExitMouseClicked
        
        int dialogButton = JOptionPane.YES_NO_OPTION;
        int dialogResult = JOptionPane.showConfirmDialog (null, "¿Desea cerrar sesión?","Confirmación",dialogButton);
        if(dialogResult == JOptionPane.YES_OPTION){ // si el usuario eligio "SI"
            this.dispose();
            Login loginView = new Login();
            loginView.setVisible(true);
            loginView.setResizable(false);
            loginView.setLocationRelativeTo(null);
        }
    }//GEN-LAST:event_lblExitMouseClicked

    private void btnAgregarUsuarioMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnAgregarUsuarioMouseClicked
        // TODO add your handling code here:
        this.dispose();
        AgregarUsuario agregarUsuario = new AgregarUsuario();
        agregarUsuario.setVisible(true);
    }//GEN-LAST:event_btnAgregarUsuarioMouseClicked

    private void btnSimulacionMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnSimulacionMouseClicked
        this.dispose();
        new Simulacion().setVisible(true);
    }//GEN-LAST:event_btnSimulacionMouseClicked

    private void btnRegistroMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnRegistroMouseClicked
        this.dispose();
        new Registro().setVisible(true);
    }//GEN-LAST:event_btnRegistroMouseClicked

    private void btnTrackingMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnTrackingMouseClicked
        this.dispose();
        BusquedaPaquete ventanaBusquedaPaquete = new BusquedaPaquete();
        ventanaBusquedaPaquete.setVisible(true);
    }//GEN-LAST:event_btnTrackingMouseClicked

    private void btnReportesMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnReportesMouseClicked
        this.dispose();
        try {
            new Reporte().setVisible(true);
        } catch (SQLException ex) {
            Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btnReportesMouseClicked

    private void btnCargaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btnCargaMouseClicked
        this.dispose();
        new CargaData().setVisible(true);
    }//GEN-LAST:event_btnCargaMouseClicked

    private void lblCambioContrasenaMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_lblCambioContrasenaMouseClicked
        
        CambiaContrasenha cambiaContrasenha = new CambiaContrasenha();
        cambiaContrasenha.setVisible(true);
    }//GEN-LAST:event_lblCambioContrasenaMouseClicked

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Menu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Menu().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnAgregarUsuario;
    private javax.swing.JButton btnCarga;
    private javax.swing.JButton btnRegistro;
    private javax.swing.JButton btnReportes;
    private javax.swing.JButton btnSimulacion;
    private javax.swing.JButton btnTracking;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel lblCambioContrasena;
    private javax.swing.JLabel lblCiudad;
    private javax.swing.JLabel lblExit;
    private javax.swing.JLabel lblNombre;
    // End of variables declaration//GEN-END:variables

}